package cn.bdqn.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;

import cn.bdqn.util.DBUtils;

public class BaseDao {
	public int executeUpdate(String sql, List args) {
		Connection connection = DBUtils.getConnection();
		try {
			PreparedStatement ps = connection.prepareStatement(sql);

			if (args != null && args.size() > 0) {

				for (int j = 0; j < args.size(); j++) {
					ps.setObject(j + 1, args.get(j));
				}
			}
			int count = ps.executeUpdate();
			ps.close();
			connection.close();
			return count;
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return -1;

	}

}
